Optimal. Leaf size=93 \[ -\frac {a^2 (A-3 i B) x}{c}+\frac {a^2 (i A+3 B) \log (\cos (e+f x))}{c f}-\frac {i a^2 B \tan (e+f x)}{c f}+\frac {2 a^2 (A-i B)}{c f (i+\tan (e+f x))} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.10, antiderivative size = 93, normalized size of antiderivative = 1.00, number of steps
used = 3, number of rules used = 2, integrand size = 41, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.049, Rules used = {3669, 78}
\begin {gather*} \frac {2 a^2 (A-i B)}{c f (\tan (e+f x)+i)}+\frac {a^2 (3 B+i A) \log (\cos (e+f x))}{c f}-\frac {a^2 x (A-3 i B)}{c}-\frac {i a^2 B \tan (e+f x)}{c f} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 78
Rule 3669
Rubi steps
\begin {align*} \int \frac {(a+i a \tan (e+f x))^2 (A+B \tan (e+f x))}{c-i c \tan (e+f x)} \, dx &=\frac {(a c) \text {Subst}\left (\int \frac {(a+i a x) (A+B x)}{(c-i c x)^2} \, dx,x,\tan (e+f x)\right )}{f}\\ &=\frac {(a c) \text {Subst}\left (\int \left (-\frac {i a B}{c^2}-\frac {2 a (A-i B)}{c^2 (i+x)^2}-\frac {i a (A-3 i B)}{c^2 (i+x)}\right ) \, dx,x,\tan (e+f x)\right )}{f}\\ &=-\frac {a^2 (A-3 i B) x}{c}+\frac {a^2 (i A+3 B) \log (\cos (e+f x))}{c f}-\frac {i a^2 B \tan (e+f x)}{c f}+\frac {2 a^2 (A-i B)}{c f (i+\tan (e+f x))}\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] Both result and optimal contain complex but leaf count is larger than twice
the leaf count of optimal. \(418\) vs. \(2(93)=186\).
time = 2.63, size = 418, normalized size = 4.49 \begin {gather*} \frac {a^2 \sec (e) \left (2 (A-3 i B) f x \cos ^3(e) \cos (e+f x)+A f x \cos (3 e) \cos (e+f x)+2 i A f x \cos (2 e) \cos (e+f x) \sin (e)+6 B f x \cos (2 e) \cos (e+f x) \sin (e)-2 i \cos ^2(e) \cos (e+f x) \left ((5 A-9 i B) f x+(-i A-3 B) \log \left (\cos ^2(e+f x)\right )\right ) \sin (e)+2 i A f x \cos (e+f x) \sin ^3(e)+6 B f x \cos (e+f x) \sin ^3(e)-2 (A-3 i B) \text {ArcTan}(\tan (3 e+f x)) \cos (e) \cos (e+f x) (\cos (2 e)-i \sin (2 e))-6 i B f x \cos (e+f x) \sin (e) \sin (2 e)+2 i B \cos (2 e) \sin (f x)+2 B \sin (2 e) \sin (f x)+\cos (e) \cos (e+f x) \left (A f x+2 (i A+B) \cos (2 f x)-i \cos (2 e) \left (6 B f x+(A-3 i B) \log \left (\cos ^2(e+f x)\right )\right )-2 A f x \sin ^2(e)+18 i B f x \sin ^2(e)-6 B f x \sin (2 e)-2 A \sin (2 f x)+2 i B \sin (2 f x)\right )\right ) (-i \cos (e+f x)+\sin (e+f x))^2 (A+B \tan (e+f x))}{2 c f (\cos (f x)+i \sin (f x))^2 (A \cos (e+f x)+B \sin (e+f x))} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.27, size = 62, normalized size = 0.67
method | result | size |
derivativedivides | \(\frac {a^{2} \left (-i B \tan \left (f x +e \right )-\frac {2 i B -2 A}{i+\tan \left (f x +e \right )}+\left (-i A -3 B \right ) \ln \left (i+\tan \left (f x +e \right )\right )\right )}{f c}\) | \(62\) |
default | \(\frac {a^{2} \left (-i B \tan \left (f x +e \right )-\frac {2 i B -2 A}{i+\tan \left (f x +e \right )}+\left (-i A -3 B \right ) \ln \left (i+\tan \left (f x +e \right )\right )\right )}{f c}\) | \(62\) |
risch | \(-\frac {{\mathrm e}^{2 i \left (f x +e \right )} B \,a^{2}}{c f}-\frac {i {\mathrm e}^{2 i \left (f x +e \right )} a^{2} A}{c f}-\frac {6 i a^{2} B e}{c f}+\frac {2 a^{2} A e}{c f}+\frac {2 a^{2} B}{f c \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )}+\frac {3 a^{2} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) B}{c f}+\frac {i a^{2} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) A}{c f}\) | \(146\) |
norman | \(\frac {\frac {\left (-3 i B \,a^{2}+2 a^{2} A \right ) \tan \left (f x +e \right )}{c f}-\frac {\left (-3 i B \,a^{2}+a^{2} A \right ) x}{c}-\frac {2 i A \,a^{2}+2 a^{2} B}{c f}-\frac {\left (-3 i B \,a^{2}+a^{2} A \right ) x \left (\tan ^{2}\left (f x +e \right )\right )}{c}-\frac {i B \,a^{2} \left (\tan ^{3}\left (f x +e \right )\right )}{c f}}{1+\tan ^{2}\left (f x +e \right )}-\frac {\left (i A \,a^{2}+3 a^{2} B \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2 c f}\) | \(165\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: RuntimeError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 3.25, size = 116, normalized size = 1.25 \begin {gather*} \frac {{\left (-i \, A - B\right )} a^{2} e^{\left (4 i \, f x + 4 i \, e\right )} + {\left (-i \, A - B\right )} a^{2} e^{\left (2 i \, f x + 2 i \, e\right )} + 2 \, B a^{2} + {\left ({\left (i \, A + 3 \, B\right )} a^{2} e^{\left (2 i \, f x + 2 i \, e\right )} + {\left (i \, A + 3 \, B\right )} a^{2}\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right )}{c f e^{\left (2 i \, f x + 2 i \, e\right )} + c f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [A]
time = 0.38, size = 134, normalized size = 1.44 \begin {gather*} \frac {2 B a^{2}}{c f e^{2 i e} e^{2 i f x} + c f} + \frac {i a^{2} \left (A - 3 i B\right ) \log {\left (e^{2 i f x} + e^{- 2 i e} \right )}}{c f} + \begin {cases} \frac {\left (- i A a^{2} e^{2 i e} - B a^{2} e^{2 i e}\right ) e^{2 i f x}}{c f} & \text {for}\: c f \neq 0 \\\frac {x \left (2 A a^{2} e^{2 i e} - 2 i B a^{2} e^{2 i e}\right )}{c} & \text {otherwise} \end {cases} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Both result and optimal contain complex but leaf count of result is larger than twice
the leaf count of optimal. 283 vs. \(2 (86) = 172\).
time = 0.63, size = 283, normalized size = 3.04 \begin {gather*} \frac {\frac {{\left (i \, A a^{2} + 3 \, B a^{2}\right )} \log \left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + 1\right )}{c} + \frac {2 \, {\left (-i \, A a^{2} - 3 \, B a^{2}\right )} \log \left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + i\right )}{c} - \frac {{\left (-i \, A a^{2} - 3 \, B a^{2}\right )} \log \left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - 1\right )}{c} - \frac {i \, A a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} + 3 \, B a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - 2 i \, B a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - i \, A a^{2} - 3 \, B a^{2}}{{\left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - 1\right )} c} - \frac {-3 i \, A a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - 9 \, B a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} + 10 \, A a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - 22 i \, B a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + 3 i \, A a^{2} + 9 \, B a^{2}}{c {\left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + i\right )}^{2}}}{f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 8.66, size = 105, normalized size = 1.13 \begin {gather*} -\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (\frac {3\,B\,a^2}{c}+\frac {A\,a^2\,1{}\mathrm {i}}{c}\right )}{f}+\frac {\frac {A\,a^2+B\,a^2\,1{}\mathrm {i}}{c}+\frac {A\,a^2-B\,a^2\,3{}\mathrm {i}}{c}}{f\,\left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )}-\frac {B\,a^2\,\mathrm {tan}\left (e+f\,x\right )\,1{}\mathrm {i}}{c\,f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________